package com.bw.router

import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.bw.base.constants.RoutePath

/**
 * 局部降级策略
 */
class LocalDegradeCallback(
    private val path: String = "",
    private val group: String = ""
) : NavigationCallback {

    /**
     *匹配到目标页面
     */
    override fun onFound(postcard: Postcard?) {

    }

    /**
     * 没有匹配到目标页面
     */
    override fun onLost(postcard: Postcard?) {
        postcard?.group = group.ifEmpty { RoutePath.GROUP_EMPTY }
        postcard?.path = path.ifEmpty { RoutePath.PATH_EMPTY }
        postcard?.navigation()
    }

    /**
     * 页面跳转成功
     */
    override fun onArrival(postcard: Postcard?) {

    }

    /**
     *页面跳转被拦截
     */
    override fun onInterrupt(postcard: Postcard?) {
    }
}